/*     */ package com.cr.business;
/*     */ 
/*     */ import com.cr.business.domain.CrUser;
/*     */ import com.cr.business.service.ICrUserService;
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import java.sql.SQLIntegrityConstraintViolationException;
import java.util.Date;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/business/user"})
/*     */ public class CrUserController extends BaseController {
/*  33 */   private String prefix = "business/user";
/*     */   
/*     */   @Autowired
/*     */   private ICrUserService crUserService;
/*     */   
/*     */   @RequiresPermissions({"business:user:view"})
/*     */   @GetMapping
/*     */   public String user() {
/*  42 */     return this.prefix + "/user";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(CrUser crUser) {
/*  53 */     startPage();
/*  54 */     crUser.setUserType(Integer.valueOf(0));
/*  55 */     List<CrUser> list = this.crUserService.selectCrUserList(crUser);
/*  56 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:export"})
/*     */   @Log(title = "用户/律师/律所信息", businessType = BusinessType.EXPORT)
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(CrUser crUser) {
/*  68 */     crUser.setUserType(Integer.valueOf(0));
/*  69 */     List<CrUser> list = this.crUserService.selectCrUserList(crUser);
/*  70 */     ExcelUtil<CrUser> util = new ExcelUtil(CrUser.class);
/*  71 */     return util.exportExcel(list, "用户/律师/律所信息数据");
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  80 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:add"})
/*     */   @Log(title = "用户/律师/律所信息", businessType = BusinessType.INSERT)
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(CrUser crUser) {
/*  92 */     crUser.setUserType(Integer.valueOf(0));
/*  93 */     try {
                return toAjax(this.crUserService.insertCrUser(crUser));
              } catch(DuplicateKeyException e){
                return AjaxResult.error("手机号码已存在,请核实");
              }
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{userId}"})
/*     */   public String edit(@PathVariable("userId") Long userId, ModelMap mmap) {
/* 102 */     CrUser crUser = this.crUserService.selectCrUserByUserId(userId);
/* 103 */     mmap.put("crUser", crUser);
/* 104 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:edit"})
/*     */   @Log(title = "用户/律师/律所信息", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(CrUser crUser) {
/* 116 */     return toAjax(this.crUserService.updateCrUser(crUser));
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:remove"})
/*     */   @Log(title = "用户/律师/律所信息", businessType = BusinessType.DELETE)
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/* 128 */     return toAjax(this.crUserService.deleteCrUserByUserIds(ids));
/*     */   }
/*     */   
/*     */   @GetMapping({"/audit/{userId}"})
/*     */   public String audit(@PathVariable("userId") Long userId, ModelMap mmap) {
/* 135 */     CrUser crUser = this.crUserService.selectCrUserByUserId(userId);
/* 136 */     mmap.put("crUser", crUser);
/* 137 */     return this.prefix + "/audit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:edit"})
/*     */   @Log(title = "用户/律师/律所信息", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/audit"})
/*     */   @ResponseBody
/*     */   public AjaxResult auditSave(CrUser crUser) {
/* 148 */     crUser.setAuditTime(new Date());
/* 149 */     return toAjax(this.crUserService.updateCrUser(crUser));
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\business\CrUserController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */